package com.faneui.transfer.gateway.utils;

public class PageUtils {
	public static String createPageHtml(int page, int pages) {
		return createPageHtml(page, pages, "queryForm", "page");
	}

	public static String createPageHtml(int page, int pages, String formname, String pageInputId) {
		StringBuffer html = new StringBuffer();
		int prePage = page - 1;
		int nextPage = page + 1;
		html.append("<div style=\"float:right\"> ");
		html.append("<input type=\"hidden\" name=\"page\" id=\"" + pageInputId + "\" value=\"" + page + "\"/>");
		html.append(
				"		                                                                                                                                  ")
				.append(" 	                                                                        ")
				.append(" 	 <a href=\"javascript:void(0);\" onclick=\"var prePage=" + prePage
						+ ";if(prePage<1)return;                                                         ")
				.append(" 	 document.getElementById('" + pageInputId + "').value=prePage;" + formname
						+ ".submit();\">上一页</a>                                                                                      ")
				.append(" 	 " + page + "/" + pages
						+ "                                                                                                        ")
				.append(" 	 <a href=\"javascript:void(0);\" onclick=\"var nextPage=" + nextPage + ";var pages=" + pages
						+ ";if(nextPage>pages||nextPage<1)return;")
				.append("		 document.getElementById('" + pageInputId + "').value=nextPage;" + formname
						+ ".submit();\">下一页</a>")
				.append(" <div>");
		return html.toString();
	}
}
